package com.erp.erp_ui.Activiti.service;

import com.erp.erp_dao.Process.IProcessDAO;
import com.erp.erp_entitys.Process.ProcessEntity;
import com.erp.erp_servers.Cost.CostService;
import com.erp.erp_servers.Customer.ICustomerService;
import com.erp.erp_servers.Customer2.ICustomer2Service;
import com.erp.erp_servers.Purchase.IPurchaseService;
import com.erp.erp_servers.business.IExportContractService;
import com.erp.erp_servers.business.IOfferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ImpProcessSerivce implements IProcessSerivce{
    @Autowired
    IProcessDAO processDAO;
    @Autowired
    ICustomerService customerService;
    @Autowired
    ICustomer2Service customer2Service;
    @Autowired
    IPurchaseService purchaseService;
    @Autowired
    CostService costService;
    /**
     * 报价接口
     */
    @Autowired
    IOfferService offerService;
    /**
     * 外销接口
     */
    @Autowired
    IExportContractService exportContractService;
    @Override
    public boolean updateStatus(String processDefKey, String bid, String spstatus) {
        boolean tf=false;
        if(processDefKey.equals("customer")) tf=customerService.updateStatus(bid,spstatus);
        if(processDefKey.equals("supplier")) tf=customer2Service.updateStatus(bid,spstatus);
        if(processDefKey.equals("purchase")) tf=purchaseService.updateStatus(bid,spstatus);
        if(processDefKey.equals("cost")) tf=costService.updateStatus(bid,spstatus);
        if(processDefKey.equals("offer")) tf=offerService.updateStatus(bid,spstatus);
        if(processDefKey.equals("export")) tf=exportContractService.updateStatus(bid,spstatus);
        return tf;
    }

    /**
     * 流程与业务编码、业务总额关联
     * @param processEntity
     * @return
     */
    @Override
    public int insert(ProcessEntity processEntity) {
        return processDAO.insert(processEntity);
    }

    /**
     * @param processId
     */
    @Override
    public ProcessEntity queryById(String processId) {
        return processDAO.queryBy(processId);
    }

    @Override
    public List<ProcessEntity> queryListById(String processIds) {
        return processDAO.queryListById(processIds);
    }
}
